#!/usr/bin/python
#coding=utf-8
# Filename: parse.py
# CreatedBy: ChenZhengguo 2011/12/7

#test_id
#form_id
#opener After logining.

import os,time
from log.log import ParseLog
from login.login import ParseLogin
from grab.grab import ParseGrab
from analyze.analyze import ParseAnalyze

def createFolder(test_id):
    if os.path.exists('swap\\'+test_id+'\\') :
        return False
    else :
        os.mkdir('swap\\'+test_id+'\\')

test_id = '10000'
createFolder(test_id)

####run time test   
starttime = time.clock()
c = ParseLogin('https://33.33.33.2/user/login',
{
'user[account]' : 'weboper',
'user[password]' : 'weboper',
'lang' : 'zh_CN',
'login' : '登  录',
})
if c.login2():
    ####run time test
    print 'login time :'+ str(time.clock() - starttime)
    starttime = time.clock()
    print c.getInfo()
    p = ParseGrab('https://33.33.33.2/ips/ruleCreate',test_id,c.getOpener(),c.getCharset())
    if p.grab2() :
        ####run time test   
        print 'Grab time :'+ str(time.clock() - starttime)
        #p.html2file('10000','origin.html') 
        print p.getError()
        #print p.getFormSerial()
    else :
        print p.getError()

a = raw_input()
